# Start off the GUI and load the waveforms that we want to monitor
vsim -gui work.Proc work.TenToOneMux work.regn work.dec3to8
add wave \
sim:/Proc/DIN \
sim:/Proc/Resetn \
sim:/Proc/Clock \
sim:/Proc/Run \
sim:/Proc/Done \
sim:/Proc/BusWires \
sim:/Proc/R0 \
sim:/Proc/R1 \
sim:/Proc/R2 \
sim:/Proc/R3 \
sim:/Proc/R4 \
sim:/Proc/R5 \
sim:/Proc/R6 \
sim:/Proc/R7 \
sim:/Proc/IR \
sim:/Proc/G \
sim:/Proc/A \
sim:/Proc/I \
sim:/Proc/Rin \
sim:/Proc/Xreg \
sim:/Proc/Yreg \
sim:/Proc/Tstep_D \
sim:/Proc/Tstep_Q \
sim:/Proc/Regout \
sim:/Proc/Gout \
sim:/Proc/DINout

#Set the clock
force -freeze sim:/Proc/Clock 1 0, 0 {50 ps} -r 100

#Initialize inputs
force -freeze sim:/Proc/Run 0 0
force -freeze sim:/Proc/Run 0 0

#Reset the processor
force -freeze sim:/Proc/Resetn 0 1
run
force -freeze sim:/Proc/Resetn 1 1
run

#Give registers initial values
force -freeze sim:/Proc/reg_0/Q 'd4 0
force -freeze sim:/Proc/reg_1/Q 'd2 0
force -freeze sim:/Proc/reg_2/Q 'd3 0
force -freeze sim:/Proc/reg_3/Q 'd7 0
force -freeze sim:/Proc/reg_4/Q 'd6 0
force -freeze sim:/Proc/reg_5/Q 'd1 0
force -freeze sim:/Proc/reg_6/Q 'd0 0
force -freeze sim:/Proc/reg_7/Q 'd2 0
run
noforce sim:/Proc/reg_0/Q
noforce sim:/Proc/reg_1/Q
noforce sim:/Proc/reg_2/Q
noforce sim:/Proc/reg_3/Q
noforce sim:/Proc/reg_4/Q
noforce sim:/Proc/reg_5/Q
noforce sim:/Proc/reg_6/Q
noforce sim:/Proc/reg_7/Q
#Start testing here. 
#TEST 1 - MV
#First we want to have the MV instruction and move from reg1 to reg0
force -freeze sim:/Proc/DIN 'b000000001 0
run
run
run
#Indicate to the processor to start - mimic a push button
force -freeze sim:/Proc/Run 1 0
run 100 ps
force -freeze sim:/Proc/Run 0 0
run 500 ps
#TEST 2 - MV
#First we want to have the MV instruction and move from reg2 to reg4
force -freeze sim:/Proc/DIN 'b000100010 0
run
run
run
#Indicate to the processor to start - mimic a push button
force -freeze sim:/Proc/Run 1 0
run 100 ps
force -freeze sim:/Proc/Run 0 0
run 500 ps
#TEST 3 - MVI
#First we want to have the MVI instruction and move to reg3 with a value of 'd1
force -freeze sim:/Proc/DIN 'b001011000 0
run
#Indicate to the processor to start - mimic a push button
force -freeze sim:/Proc/Run 1 0
run 100 ps
force -freeze sim:/Proc/Run 0 0
force -freeze sim:/Proc/DIN 'b000000001 0
run 500 ps
#TEST 4 - ADD
#First we want to have the ADD instruction execute reg0 + reg1
force -freeze sim:/Proc/DIN 'b010000001 0
run
#Indicate to the processor to start - mimic a push button
force -freeze sim:/Proc/Run 1 0
run 100 ps
force -freeze sim:/Proc/Run 0 0
run 500 ps
#TEST 4 - SUM
#First we want to have the SUB instruction execute reg0 - reg1
force -freeze sim:/Proc/DIN 'b011000001 0
run
#Indicate to the processor to start - mimic a push button
force -freeze sim:/Proc/Run 1 0
run
force -freeze sim:/Proc/DIN 'b000000001 0
run
run
run 100 ps
force -freeze sim:/Proc/Run 0 0
run 500 ps